
class_name CRewardFlow

extends EventDispatcher

signal UUID_changed(old_value, new_value) 
signal CharID_changed(old_value, new_value) 
signal ActionType_changed(old_value, new_value) 
signal Rewards_changed(old_value, new_value) 
signal Info_changed(old_value, new_value) 


var m_tblAlias
var bInited = false
func _init(_uuid)->void:
    self.UUID = _uuid
    self.CharID = 0
    self.ActionType = 0
    self.Rewards = ''
    self.Info = ''

    self.m_tblAlias = {
 
    }

func UnPack(_bufferStream):
    self.UUID = _bufferStream.ReadInt64()
    self.CharID = _bufferStream.ReadInt64()
    self.ActionType = _bufferStream.ReadUint32()
    self.Rewards = _bufferStream.ReadBytes(TableCommonDefine.ECharLen.eCL_Rewards)
    self.Info = _bufferStream.ReadString(TableCommonDefine.ECharLen.eCL_Info)

    self.bInited = true


func GetTableName():
    return 'RewardFlow'

func CopyFrom(other):
    self.CharID = other.CharID
    self.ActionType = other.ActionType
    self.Rewards = other.Rewards
    self.Info = other.Info


func OnDataChanged( fieldName, oldValue, newValue):
    if oldValue == newValue:
        return
    
    self.DispatchEvent(fieldName, [self, oldValue, newValue])
    #  Alias
    if self.m_tblAlias[fieldName] != null:
        for i in range(self.m_tblAlias[fieldName].size()):
            self.DispatchEvent(self.m_tblAlias[fieldName][i], [self, oldValue, newValue])

func UnPackField(_fieldId, _bufferStream, _varLen ):
    if _fieldId < 0 or _fieldId == 0xffff:
        var old = CRewardFlow.new(self.m_UUID)
        old.CopyFrom( self )
        self.UnPack( _bufferStream )
        self.DispatchEvent("CRewardFlow", [self, old, self])
        return true

    print("UnPackField error tblName = RewardFlow, className = CRewardFlow, _fieldId = ", _fieldId)
    # if _fieldId > Fields_RewardFlowID.size():
    #     var szLog = 'CRewardFlow.UnPackField  _fieldId(%d) < 0 or _fieldId(%d) > #Fields_RewardFlowID(%d)' % [_fieldId, _fieldId,  Fields_RewardFlowID.size()]
    #     print(szLog)
    #     return false

    # Fields_RewardFlowID[_fieldId].reader( self, _bufferStream, _varLen)

    return true

func AddField(_fieldId, _bufferStream):
    print( "[TABLEDATA] error AddField", "CRewardFlow", _fieldId )

    
func DelField(_fieldId ):
    print( "[TABLEDATA] error DelField", "CRewardFlow", _fieldId )

var UUID:
    set(value):
        var old = self.m_UUID
        self.UUID = _value
        self.UUID_changed.emit(old, _value)

    get:
        return self.UUID


var CharID:
    set(value):
        var old = self.m_CharID
        self.CharID = _value
        self.CharID_changed.emit(old, _value)

    get:
        return self.CharID


var ActionType:
    set(value):
        var old = self.m_ActionType
        self.ActionType = _value
        self.ActionType_changed.emit(old, _value)

    get:
        return self.ActionType


var Rewards:
    set(value):
        var old = self.m_Rewards
        self.Rewards = _value
        self.Rewards_changed.emit(old, _value)

    get:
        return self.Rewards


var Info:
    set(value):
        var old = self.m_Info
        self.Info = _value
        self.Info_changed.emit(old, _value)

    get:
        return self.Info



